\(\int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx\) [29]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 24, antiderivative size = 94 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {5 a^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 i a^2 \sec ^3(c+d x)}{12 d}+\frac {5 a^2 \sec (c+d x) \tan (c+d x)}{8 d}+\frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d} \]

[Out]

5/8*a^2*arctanh(sin(d*x+c))/d+5/12*I*a^2*sec(d*x+c)^3/d+5/8*a^2*sec(d*x+c)*tan(d*x+c)/d+1/4*I*sec(d*x+c)^3*(a^
2+I*a^2*tan(d*x+c))/d

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3579, 3567, 3853, 3855} \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {5 a^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 i a^2 \sec ^3(c+d x)}{12 d}+\frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d}+\frac {5 a^2 \tan (c+d x) \sec (c+d x)}{8 d} \]

[In]

Int[Sec[c + d*x]^3*(a + I*a*Tan[c + d*x])^2,x]

[Out]

(5*a^2*ArcTanh[Sin[c + d*x]])/(8*d) + (((5*I)/12)*a^2*Sec[c + d*x]^3)/d + (5*a^2*Sec[c + d*x]*Tan[c + d*x])/(8
*d) + ((I/4)*Sec[c + d*x]^3*(a^2 + I*a^2*Tan[c + d*x]))/d

Rule 3567

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*((d*Sec[
e + f*x])^m/(f*m)), x] + Dist[a, Int[(d*Sec[e + f*x])^m, x], x] /; FreeQ[{a, b, d, e, f, m}, x] && (IntegerQ[2
*m] || NeQ[a^2 + b^2, 0])

Rule 3579

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(d*
Sec[e + f*x])^m*((a + b*Tan[e + f*x])^(n - 1)/(f*(m + n - 1))), x] + Dist[a*((m + 2*n - 2)/(m + n - 1)), Int[(
d*Sec[e + f*x])^m*(a + b*Tan[e + f*x])^(n - 1), x], x] /; FreeQ[{a, b, d, e, f, m}, x] && EqQ[a^2 + b^2, 0] &&
 GtQ[n, 0] && NeQ[m + n - 1, 0] && IntegersQ[2*m, 2*n]

Rule 3853

Int[(csc[(c_.) + (d_.)*(x_)]*(b_.))^(n_), x_Symbol] :> Simp[(-b)*Cos[c + d*x]*((b*Csc[c + d*x])^(n - 1)/(d*(n
- 1))), x] + Dist[b^2*((n - 2)/(n - 1)), Int[(b*Csc[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n,
 1] && IntegerQ[2*n]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d}+\frac {1}{4} (5 a) \int \sec ^3(c+d x) (a+i a \tan (c+d x)) \, dx \\ & = \frac {5 i a^2 \sec ^3(c+d x)}{12 d}+\frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d}+\frac {1}{4} \left (5 a^2\right ) \int \sec ^3(c+d x) \, dx \\ & = \frac {5 i a^2 \sec ^3(c+d x)}{12 d}+\frac {5 a^2 \sec (c+d x) \tan (c+d x)}{8 d}+\frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d}+\frac {1}{8} \left (5 a^2\right ) \int \sec (c+d x) \, dx \\ & = \frac {5 a^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 i a^2 \sec ^3(c+d x)}{12 d}+\frac {5 a^2 \sec (c+d x) \tan (c+d x)}{8 d}+\frac {i \sec ^3(c+d x) \left (a^2+i a^2 \tan (c+d x)\right )}{4 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.13 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.89 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {5 a^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {2 i a^2 \sec ^3(c+d x)}{3 d}+\frac {5 a^2 \sec (c+d x) \tan (c+d x)}{8 d}-\frac {a^2 \sec ^3(c+d x) \tan (c+d x)}{4 d} \]

[In]

Integrate[Sec[c + d*x]^3*(a + I*a*Tan[c + d*x])^2,x]

[Out]

(5*a^2*ArcTanh[Sin[c + d*x]])/(8*d) + (((2*I)/3)*a^2*Sec[c + d*x]^3)/d + (5*a^2*Sec[c + d*x]*Tan[c + d*x])/(8*
d) - (a^2*Sec[c + d*x]^3*Tan[c + d*x])/(4*d)

Maple [A] (verified)

Time = 3.99 (sec) , antiderivative size = 111, normalized size of antiderivative = 1.18

method result size
risch \(-\frac {i a^{2} \left (15 \,{\mathrm e}^{7 i \left (d x +c \right )}-73 \,{\mathrm e}^{5 i \left (d x +c \right )}-55 \,{\mathrm e}^{3 i \left (d x +c \right )}-15 \,{\mathrm e}^{i \left (d x +c \right )}\right )}{12 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {5 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{8 d}-\frac {5 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{8 d}\) \(111\)
derivativedivides \(\frac {-a^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )+\frac {2 i a^{2}}{3 \cos \left (d x +c \right )^{3}}+a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) \(121\)
default \(\frac {-a^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )+\frac {2 i a^{2}}{3 \cos \left (d x +c \right )^{3}}+a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) \(121\)

[In]

int(sec(d*x+c)^3*(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

-1/12*I*a^2/d/(exp(2*I*(d*x+c))+1)^4*(15*exp(7*I*(d*x+c))-73*exp(5*I*(d*x+c))-55*exp(3*I*(d*x+c))-15*exp(I*(d*
x+c)))+5/8/d*a^2*ln(exp(I*(d*x+c))+I)-5/8/d*a^2*ln(exp(I*(d*x+c))-I)

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 256 vs. \(2 (80) = 160\).

Time = 0.25 (sec) , antiderivative size = 256, normalized size of antiderivative = 2.72 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {-30 i \, a^{2} e^{\left (7 i \, d x + 7 i \, c\right )} + 146 i \, a^{2} e^{\left (5 i \, d x + 5 i \, c\right )} + 110 i \, a^{2} e^{\left (3 i \, d x + 3 i \, c\right )} + 30 i \, a^{2} e^{\left (i \, d x + i \, c\right )} + 15 \, {\left (a^{2} e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + a^{2}\right )} \log \left (e^{\left (i \, d x + i \, c\right )} + i\right ) - 15 \, {\left (a^{2} e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + a^{2}\right )} \log \left (e^{\left (i \, d x + i \, c\right )} - i\right )}{24 \, {\left (d e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, d e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(sec(d*x+c)^3*(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/24*(-30*I*a^2*e^(7*I*d*x + 7*I*c) + 146*I*a^2*e^(5*I*d*x + 5*I*c) + 110*I*a^2*e^(3*I*d*x + 3*I*c) + 30*I*a^2
*e^(I*d*x + I*c) + 15*(a^2*e^(8*I*d*x + 8*I*c) + 4*a^2*e^(6*I*d*x + 6*I*c) + 6*a^2*e^(4*I*d*x + 4*I*c) + 4*a^2
*e^(2*I*d*x + 2*I*c) + a^2)*log(e^(I*d*x + I*c) + I) - 15*(a^2*e^(8*I*d*x + 8*I*c) + 4*a^2*e^(6*I*d*x + 6*I*c)
 + 6*a^2*e^(4*I*d*x + 4*I*c) + 4*a^2*e^(2*I*d*x + 2*I*c) + a^2)*log(e^(I*d*x + I*c) - I))/(d*e^(8*I*d*x + 8*I*
c) + 4*d*e^(6*I*d*x + 6*I*c) + 6*d*e^(4*I*d*x + 4*I*c) + 4*d*e^(2*I*d*x + 2*I*c) + d)

Sympy [F]

\[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=- a^{2} \left (\int \tan ^{2}{\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\, dx + \int \left (- 2 i \tan {\left (c + d x \right )} \sec ^{3}{\left (c + d x \right )}\right )\, dx + \int \left (- \sec ^{3}{\left (c + d x \right )}\right )\, dx\right ) \]

[In]

integrate(sec(d*x+c)**3*(a+I*a*tan(d*x+c))**2,x)

[Out]

-a**2*(Integral(tan(c + d*x)**2*sec(c + d*x)**3, x) + Integral(-2*I*tan(c + d*x)*sec(c + d*x)**3, x) + Integra
l(-sec(c + d*x)**3, x))

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 130, normalized size of antiderivative = 1.38 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=-\frac {3 \, a^{2} {\left (\frac {2 \, {\left (\sin \left (d x + c\right )^{3} + \sin \left (d x + c\right )\right )}}{\sin \left (d x + c\right )^{4} - 2 \, \sin \left (d x + c\right )^{2} + 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 12 \, a^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - \frac {32 i \, a^{2}}{\cos \left (d x + c\right )^{3}}}{48 \, d} \]

[In]

integrate(sec(d*x+c)^3*(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/48*(3*a^2*(2*(sin(d*x + c)^3 + sin(d*x + c))/(sin(d*x + c)^4 - 2*sin(d*x + c)^2 + 1) - log(sin(d*x + c) + 1
) + log(sin(d*x + c) - 1)) + 12*a^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(sin(d*x + c) + 1) + log(sin(d*x
 + c) - 1)) - 32*I*a^2/cos(d*x + c)^3)/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 173 vs. \(2 (80) = 160\).

Time = 0.51 (sec) , antiderivative size = 173, normalized size of antiderivative = 1.84 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {15 \, a^{2} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1\right ) - 15 \, a^{2} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1\right ) + \frac {2 \, {\left (9 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{7} - 48 i \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{6} - 33 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 48 i \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 33 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 16 i \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 9 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 16 i \, a^{2}\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{4}}}{24 \, d} \]

[In]

integrate(sec(d*x+c)^3*(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/24*(15*a^2*log(tan(1/2*d*x + 1/2*c) + 1) - 15*a^2*log(tan(1/2*d*x + 1/2*c) - 1) + 2*(9*a^2*tan(1/2*d*x + 1/2
*c)^7 - 48*I*a^2*tan(1/2*d*x + 1/2*c)^6 - 33*a^2*tan(1/2*d*x + 1/2*c)^5 + 48*I*a^2*tan(1/2*d*x + 1/2*c)^4 - 33
*a^2*tan(1/2*d*x + 1/2*c)^3 - 16*I*a^2*tan(1/2*d*x + 1/2*c)^2 + 9*a^2*tan(1/2*d*x + 1/2*c) + 16*I*a^2)/(tan(1/
2*d*x + 1/2*c)^2 - 1)^4)/d

Mupad [B] (verification not implemented)

Time = 7.32 (sec) , antiderivative size = 198, normalized size of antiderivative = 2.11 \[ \int \sec ^3(c+d x) (a+i a \tan (c+d x))^2 \, dx=\frac {5\,a^2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{4\,d}-\frac {-\frac {3\,a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^7}{4}+a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6\,4{}\mathrm {i}+\frac {11\,a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5}{4}-a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\,4{}\mathrm {i}+\frac {11\,a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3}{4}+\frac {a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,4{}\mathrm {i}}{3}-\frac {3\,a^2\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{4}-\frac {a^2\,4{}\mathrm {i}}{3}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+6\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )} \]

[In]

int((a + a*tan(c + d*x)*1i)^2/cos(c + d*x)^3,x)

[Out]

(5*a^2*atanh(tan(c/2 + (d*x)/2)))/(4*d) - ((a^2*tan(c/2 + (d*x)/2)^2*4i)/3 + (11*a^2*tan(c/2 + (d*x)/2)^3)/4 -
 a^2*tan(c/2 + (d*x)/2)^4*4i + (11*a^2*tan(c/2 + (d*x)/2)^5)/4 + a^2*tan(c/2 + (d*x)/2)^6*4i - (3*a^2*tan(c/2
+ (d*x)/2)^7)/4 - (a^2*4i)/3 - (3*a^2*tan(c/2 + (d*x)/2))/4)/(d*(6*tan(c/2 + (d*x)/2)^4 - 4*tan(c/2 + (d*x)/2)
^2 - 4*tan(c/2 + (d*x)/2)^6 + tan(c/2 + (d*x)/2)^8 + 1))